Skip to main content

All Questions

7votes
6answers
753views

Split column into lines using awk

I have a file that contains a long column and I want to split it into lines, each one with 5 values. E.g., Input file: 1 2 3 4 5 6 7 8 9 10 Output file: 1 2 3 4 5 6 7 8 9 10
Djabri Josef's user avatar
0votes
1answer
193views

How to search in a pdf or text file by a regex pattern and output locations of matches?

Is there a pdf viewer that allows me to search its text by a regex expression? In case that I haven't found one, I am thinking about extracting the text and layout from a pdf file by less my.pdf > ...
Tim's user avatar
  • 106k
1vote
2answers
165views

Reformat text to exact width [duplicate]

On Ubuntu, how to reformat text to fit width (except final line), adding spaces where necessary? The closest I can get is with fmt --width=64, but this does not add the spaces between words. Input ...
FromTheStackAndBack's user avatar
0votes
0answers
104views

Geany: Possible to automatically enable/disable line wrap dependent on file type?

In Geany text editor / IDE, is there a way to tell it to automatically enable line wrapping for certain file types, but not for others? For example, for .txt files, I would like it to always enable ...
Amazon Dies In Darkness's user avatar
1vote
2answers
2kviews

Converting a TXT file to PDF from the command line using a custom font

I want to convert a UTF-8 txt file to PDF for printing with CUPS. The problem I'm facing is that all tools I've tried have either failed to format the PDF (resulting in a fully white document with no ...
psvg200's user avatar
1vote
4answers
150views

Find text files where the content is duplicated?

By mistake I appended (>>) rather than overwrote (>) the output from a script that processed thousands of files, but I only did it for about 20 % of the files (I ran 5 parallel instances of ...
d-b's user avatar
  • 2,047
1vote
3answers
272views

Remove lines matching pattern, plus any lines following it matching a different pattern

Let me preface I am not sure if this question has been asked before, I have been Googling for answers but came up short. I want to use standard Linux/Unix commands (running this on FreeBSD) to exclude ...
ekrekeler's user avatar
1vote
1answer
115views

How to separate with a comma in a logfile

I have a log file as below, 011122111128 :16267281288 :40586200370017022 :947700000622 :919400146760221 :SSD :4065376D : :9477000006 :9170120275030 :210 :18 :002919544716189 :unknown :unknown :unknown ...
edublog's user avatar
2votes
4answers
933views

How can I match text at the beginning of a line and print the X previous lines along with the matched one?

I found a similar question here, but it is not exactly what I want. Let's suppose I have a text file like this: [...] age: 10 country: United States city: New York name: John age: 27 country: Canada ...
phantomcraft's user avatar
4votes
4answers
748views

Convert all small words (2-3 characters) to upper case with awk or sed

I need all 2-3 character words completely capitalized. 1 character and 4+ character words need to be remain untouched. Input: cat Example Dog I Fish su Su adm Amd Cat ignore Expected output: CAT ...
xorghelpneed's user avatar
3votes
2answers
255views

Indent lines of text following given rule

I was wondering how indenting recursively more and more lines of poetry following a custom rule. For instance Let say we have: OF Mans First Disobedience, and the Fruit Of that Forbidden Tree, whose ...
Dingo's user avatar
2votes
2answers
942views

replacement for tr with utf-8 capabilities

in order to isolate the last word in any line of a poem (to have a list of all rhymes), I put together several snippets of code obtaining this awk '{print $NF}' input.txt | tr 'A-Z' 'a-z' | tr -sc 'a-...
Dingo's user avatar
1vote
3answers
66views

Restarting poem line numbering any 4 lines after a blank space

This is related to very interesting answer given here: Any text utility or hack to numbering poems lines omitting certain numbers? awk 'FNR % 4 == 0 { printf "%6i %s\n", FNR, $0 ; next }; {...
Dingo's user avatar
7votes
6answers
1kviews

Uppercasing first letter of a line after period in previous line

I have many little poems to edit like this: Io avevo due sorelle, una bionda e l’altra mora, tutte e due leggiadre e belle e gentil come l’aurora. ma la bionda mi è sparita, se ne è andata all’altra ...
Dingo's user avatar
3votes
3answers
673views

Numbering poems stanzas using roman numerals

I would be able to numbering, sequentially, any stanza of a certain poem using roman numerals like this: Injurious love, why still to mar accord Between desires has been thy ...
Dingo's user avatar

153050per page
close